// pages/my/my.js
const app = getApp()

Page({

  /**  
   * 页面的初始数据  
   */
  data: {
    avatarUrl: '',
    nickName: ''
  },
  /**  
   * 生命周期函数--监听页面加载  
   */
  onLoad: function (options) {
    var that = this
    var userInfo = wx.getStorageSync('userinfo')
    if (userInfo != ''){
      that.setData({
        avatarUrl: userInfo.avatarUrl,
        nickName: userInfo.nickName
      })
    }
  },
  getUserInfo: function () {
    var that = this;
    wx.getUserInfo({
      // lang: 'zh_CN',
      success: function (res) {
        wx.setStorageSync('userinfo', res.userInfo)
        that.setData({
          avatarUrl: res.userInfo.avatarUrl,
          nickName: res.userInfo.nickName
        })
      },
      fail: function (res) {
        console.log(res)
      }
    })
  },
  opinion:function(){
    wx.navigateTo({
      url: '/pages/personal/opinion/opinion'
    })
  },
  about: function () {
    wx.navigateTo({
      url: '/pages/personal/about/about'
    })
  },
  submitted: function () {
    var that = this;
    var contactName = wx.getStorageSync('contactName1')
    var contactPassword = wx.getStorageSync('contactPassword1')
    if (contactName != '' && contactPassword != '') {
      wx.navigateTo({
        url: '/pages/personal/submitted/submitted'
      })
    }else{
      wx.navigateTo({
        url: '/pages/login/login'
      })
    }
  },
  company: function () {
    var that = this;
    var contactName = wx.getStorageSync('contactName2')
    var contactPassword = wx.getStorageSync('contactPassword2')
    if (contactName != '' && contactPassword != '') {
      wx.navigateTo({
        url: '/pages/personal/company/company'
      })
    } else {
      wx.navigateTo({
        url: '/pages/personal/login/login'
      })
    }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.onLoad()
  },
})